from MyTools.DBUtils import DBUtils


class LoanDAO:
    def __init__(self):
        self.db = DBUtils(password='root', database='finance')

    def get_all_loan(self, userid, apply_status=0, loan_status=0):
        sql = "SELECT `amount`,`term` FROM `loan` WHERE `userid` = %s AND `applyStatus` = %s AND `loanStatus` = %s"
        return self.db.select(sql, (userid, apply_status, loan_status))

    def clean_loan(self):
        sql = 'DELETE FROM `loan`'
        self.db.update(sql)

